using Senparc.Weixin.MP.Entities.BaiduMap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Senparc.Weixin.MP.Helpers
{
	public static class BaiduMapHelper
	{
		public static string GetBaiduStaticMap(double lng, double lat, int scale, int zoom, IList<BaiduMarkers> markersList, int width = 400, int height = 300)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("http://api.map.baidu.com/staticimage?");
			stringBuilder.AppendFormat("center={0},{1}", lng, lat);
			stringBuilder.AppendFormat("&width={0}", width);
			stringBuilder.AppendFormat("&height={0}", height);
			stringBuilder.AppendFormat("&scale={0}", scale);
			stringBuilder.AppendFormat("&zoom={0}", zoom);
			if (markersList != null && markersList.Count > 0)
			{
				stringBuilder.AppendFormat("&markers={0}", string.Join("|", (
					from z in markersList
					select string.Format("{0},{1}", z.Longitude, z.Latitude)).ToArray<string>()));
				stringBuilder.AppendFormat("&markerStyles={0}", string.Join("|", (
					from z in markersList
					select string.Format("{0},{1},{2}", z.Size.ToString(), z.Label, z.Color)).ToArray<string>()));
			}
			return stringBuilder.ToString();
		}
	}
}
